package iterator.impl;

import iterator.Container;
import iterator.Iterator;
import iterator.iterator.PersonIterator;
import iterator.iterator.StudentIterator;

//容器
public class PersonContainer implements Container {
    public Object[] container;
    private int pointer;
    private int curr;
    public int size = 0;

    public PersonContainer(int capcy) {
        this.size = capcy;
        container = new Object[capcy];
    }

    public void add(Object object) {
        if (pointer >= size) return;
        container[pointer++] = object;
    }

    public Object get(int i) {
        return container[i];
    }

    @Override
    public Iterator getIterator() {
        curr=0;
        return new PersonIterator(this);
    }

    @Override
    public Iterator getStudentIterator() {
        curr=0;
        return new StudentIterator(this);
    }
}
